<?php
namespace app\index\controller;
use app\index\model\Login_model;
use think\Session;
use think\Controller;
use think\Db;
use weibosdk\saetoauthv;
header("Content-type: text/html; charset=utf-8");
//首页
class Login extends Controller
{
	public function login()
	{
		$Goods = new Login_model;
		$code_url   = $Goods->code_url();
		$weixin_url = $Goods->weixin_url();
		$qq_url     = $Goods->qq_url();
		$this->assign('code_url',$code_url);
		$this->assign('weixin_url',$weixin_url);
		$this->assign('qq_url',$qq_url);
		return view('login');
	}

	//登陆
	public function login_form()
	{
		$params = input();
        $Goods = new Login_model;
        $sele_sql = $Goods->login($params);
        return $this->redirect('index/index');   
	}

	//手机验证码
	public function yzm()
	{
		$params = input('tel');
        $Goods = new Login_model;
        $yzm = $Goods->yzm($params);
        return ;
	}

	//注册
	public function registered()
	{
		return view('registered');
	} 
	public function registered_add()
	{
		$params = input();
        $Goods = new Login_model;
        $registered = $Goods->registered($params);
        return $this->redirect('login/login');   
	} 

	//微博授权
	public function weibo()
	{

		$Goods = new Login_model;
        $registered = $Goods->weibo();
        return $this->redirect('index/index');   
	}

	//微博取消授权
	public function weibo_cancel()
    {
        return $this->redirect('login/login');   
    }


    //微信授权
    public function weixin()
	{
		$params = input();
		$Goods = new Login_model;
        $registered = $Goods->weixin($params);
        return $this->redirect('index/index');   
	}

	//QQ授权
	public function qqlogin()
	{
		$params = input();
		$Goods = new Login_model;
        $registered = $Goods->qqlogin($params);
        return $this->redirect('index/index');   
	}

	//删除session
	public function session(){
		session('username',null); // 删除name
		session('datatime',null); // 删除登陆时间
		session('ip',null); 	  // 删除IP地址
		session('country',null);  // 删除地区
		session('province',null); // 删除地区
		session('city',null);     // 删除地区
		return $this->redirect('login/login');   
	}
}